<template>
	<view class="content">
		<Loading :show="loading"></Loading>
	    <uni-card :title="item.title" :extra="switchExtra(item.situation)" v-for="(item,index) in list" :key="index"> 
		     <view class="uCard-font"  >类型:&#12288;{{switchTable(item.table)}}</view>
	         <view class="uCard-font"  >地址:&#12288;{{item.address}}</view>
			 <view  class="uCard-font"  >房源:&#12288;{{item.title}}</view>
			 <view  class="uCard-font" >预留号码:&#12288;{{item.phone}}</view>
			
			 <view  class="uCard-font">预约时间:&#12288;{{item.create_time}}</view>
	        <view class="uCard-bottom" v-show="item.situation == -1 ">
				<u-line color="#b8b8b8" />
				<view style="margin-top: 10rpx;">跟进失败原因:&#12288;{{failure(item.reason)}}</view>
			</view>
		</uni-card>
	</view>
</template>

<script>
	import { subscribeList } from "@/services/subscribe.js"
	import  Loading from  "@/components/loading/loading.vue"
	import UniCard from "@/components/uni-card/uni-card"
 	export default {
		components:{
			Loading,
			UniCard
		},
		data() {
			return {
				loading:true,
				list:[],
			}
		},
		created(){
			this.freeDistributionListLoad()
		},
		methods: {
			 async freeDistributionListLoad(){
				   this.loading = true
					let res = await  subscribeList()
					if(res.code == 200){
						this.list = res.data
					}
					 
					this.$nextTick(()=>{
						this.loading = false
					}) 
			 },
			 failure(msg){
				 if(this.checkField(msg)){
					let field = JSON.parse(msg)
					if(field.hasOwnProperty(-1)){
						return field[-1]
					}else{
						return '未填写'
					} 
				 }else{
					 return '未填写'
				 }
			 },
			 switchExtra(extra){
				 switch(extra){
					 case -1:
					 return '跟进失败'  
					 case 0:
					 return '未跟进'
					 case 1:
					 return '跟进中'
					 case 2:
					 return '跟进完成'
				 }
			 },
			 switchTable(table){
			 				 switch(table){
			 					 case 'housing':
			 					 return '写字楼'  
			 					 case 'store':
			 					 return '商铺'
			 					 case 'building':
			 					 return '大厦'
			 				 }
			 }
		}
	}
</script>

<style scoped lang="less">
      .content{
		  width: 100%;
		  padding-bottom: 50rpx;
		  
		  .uCard-font{
			  font-size: 30rpx;
			  width: 100%;
			  line-height: 50rpx;
			  // border: 1rpx solid red;
			  
			  word-wrap:break-word;
		  }
		  .uCard-bottom{
			  margin-top: 20rpx;
		  }
	  }
</style>
